package com.itheima.dao;

import com.itheima.pojo.OrderSetting;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface OrderSettingDao {

    @Select("select count(*) from t_ordersetting where orderDate=#{orderDate}")
    public long searchOrderSettingByDate(@Param("orderDate") String OrderDate);

    @Insert("insert into t_ordersetting values(null,#{orderDate},#{number},#{reservations})")
    public void addOrderSetting(OrderSetting orderSetting);

    @Update("update t_ordersetting set number=#{number} where orderDate=#{orderDate}")
    public void editOrderSetting(OrderSetting orderSetting);

    @Select("select * from t_ordersetting where orderDate between #{firstDate} and #{lastDate}")
    public List<OrderSetting> searchOrderSettingByMonth(@Param("firstDate") String firstDate,@Param("lastDate") String lastDate);

    @Select("select number,reservations from t_ordersetting where orderDate=#{orderDate}")
    public Map<String,Integer> searchReservations(@Param("orderDate") String orderDate);

    @Update("update t_ordersetting set reservations=reservations+1 where orderDate=#{orderDate}")
    public void editOrderSettingReservations(@Param("orderDate") Date date);
}
